/*
*  Copyright 2019-2020 Zheng Jie
*
*  Licensed under the Apache License, Version 2.0 (the "License");
*  you may not use this file except in compliance with the License.
*  You may obtain a copy of the License at
*
*  http://www.apache.org/licenses/LICENSE-2.0
*
*  Unless required by applicable law or agreed to in writing, software
*  distributed under the License is distributed on an "AS IS" BASIS,
*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*  See the License for the specific language governing permissions and
*  limitations under the License.
*/
package me.zhengjie.repository;

import me.zhengjie.domain.KwExamStudent;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

/**
* @website https://el-admin.vip
* @author LongYang
* @date 2021-06-28
**/
public interface KwExamStudentRepository extends JpaRepository<KwExamStudent, Integer>, JpaSpecificationExecutor<KwExamStudent> {
    /**
     * 根据考试id和考生号查询
     * @param examId 考试id
     * @param examinee 考生号
     */
    @Query(value = "select * from kw_exam_student WHERE exam_id=?1 AND examinee=?2",nativeQuery = true)
    List<KwExamStudent> findByExamIdAndExamInee(Integer examId, String examinee);

    /**
     * 根据教室id和座位号查询
     * @param examRoomId 考场id
     * @return
     */
    @Query(value = "select * from kw_exam_student WHERE exam_id=?1 AND exam_room_id=?2",nativeQuery = true)
    List<KwExamStudent> findByExamIdAndExamRoomId(Integer examId,Integer examRoomId);

    /**
     * 根据教室id查询是否拥有学生安排下信息
     * @param id
     * @return
     */
    List<KwExamStudent> findByRoomId(Integer id);
}